package hungary;

// 这算是一个解
public class Problem {
    private int n; // 矩阵阶数
    private int[][] cost; // 成本矩阵，hungary矩阵

    // 用来标出哪个位置是零元素（0表示无零元素，1表示圈中此零元素，2表示划去此零元素）
    // 0表示这一行(列)无独立零元素，1表示这一行(列)由独立零元素，2表示这一行(列)打勾
    private int[][] zero;

    public Problem(int[][] cost) {
        this.n = cost.length - 1;

        this.cost = new int[cost.length][cost[0].length];
        for (int i = 0; i < cost.length; i++) {
            for (int j = 0; j < cost[i].length; j++) {
                this.cost[i][j] = cost[i][j];
            }
        }

        this.zero = new int[this.n + 1][this.n + 1];
        for (int i = 0; i <= this.n; i++) {
            for (int j = 0; j <= this.n; j++) {
                this.zero[i][j] = 0;
            }
        }
    }

    public Problem(Problem p) {
        this.n = p.n;

        if (p.cost != null) {
            this.cost = new int[p.cost.length][p.cost[0].length];
            for (int i = 0; i < p.cost.length; i++) {
                for (int j = 0; j < p.cost[i].length; j++) {
                    this.cost[i][j] = p.cost[i][j];
                }
            }
        }

        if (p.zero != null) {
            this.zero = new int[p.zero.length][p.zero[0].length];
            for (int i = 0; i < p.zero.length; i++) {
                for (int j = 0; j < p.zero[i].length; j++) {
                    this.zero[i][j] = p.zero[i][j];
                }
            }
        }
    }

    public int getN() {
        return n;
    }

    public int[][] getCost() {
        return cost;
    }

    public int[][] getZero() {
        return zero;
    }
}